﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace NJL.Web
{
    public partial class MoreLocalColor : BasePageVisitor
    {
        NJL.BLL.NJL_LOCAL_COLOR bllLocalColor = new BLL.NJL_LOCAL_COLOR();
        NJL.BLL.NJL_CS_LOCAL_COLOR_TYPE localType = new BLL.NJL_CS_LOCAL_COLOR_TYPE();
        NJL.Model.NJL_CS_LOCAL_COLOR_TYPE modelType;
        private readonly BLL.NJL_CS_TAG bllTag = new BLL.NJL_CS_TAG();
        protected IList<Model.NJL_CS_TAG> LIST_TAG;
        protected void Page_Load(object sender, EventArgs e)
        {
            #region 标签
            if (WEBSITE_FOCUS_CITY_CODE != "")
            {
                LIST_TAG = bllTag.GetModelList(15, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and TAG_TYPE='2' and AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "'", "SEARCH_COUNT desc,USED_COUNT DESC");
            }
            else
            {
                LIST_TAG = bllTag.GetModelList(15, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and TAG_TYPE='2'", "SEARCH_COUNT desc,USED_COUNT DESC");
            }
            #endregion
            if (!IsPostBack)
            {   
                modelType=localType.GetModel(Request.QueryString["typeid"]);
                ltlTypeName.Text = modelType.TYPE_NAME;
                ltlTypeName1.Text = modelType.TYPE_NAME;
                DataSet ds;
                if (WEBSITE_FOCUS_CITY_CODE == "")
                {
                    ds = bllLocalColor.GetAllList("NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and TYPE_CODE='" + Request.QueryString["typeid"] + "'");
                    if (ds.Tables[0].Rows.Count > 10)
                    {
                        pager.InnerHtml = Royalsoft.Common.Pager.GetPageNum(ds, rptLocalColor, 10, new string[] { "typeid" }, "/dfts/" + Request.QueryString["typeid"] + "/");
                    }
                    else
                    {
                        rptLocalColor.DataSource = ds;
                        rptLocalColor.DataBind();
                    }
                }
                else
                {
                    ds = bllLocalColor.GetAllList("NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and TYPE_CODE='" + Request.QueryString["typeid"] + "' and AREA_CODE='"+WEBSITE_FOCUS_CITY_CODE+"'");
                    if (ds.Tables[0].Rows.Count > 10)
                    {
                        pager.InnerHtml = Royalsoft.Common.Pager.GetPageNum(ds, rptLocalColor, 10, new string[] { "typeid" }, "/" + WEBSITE_FOCUS_CITY_NAME_PINYIN + "/dfts/"+Request.QueryString["typeid"]+"/");
                    }
                    else
                    {
                        rptLocalColor.DataSource = ds;
                        rptLocalColor.DataBind();
                    }
                }
                Page.Title = "地方特色_" + modelType.TYPE_NAME;
                #region 本季特色
                NJL.BLL.NJL_COMPANY_SERVICE bllService = new BLL.NJL_COMPANY_SERVICE();
                if (WEBSITE_FOCUS_CITY_CODE != "")
                {
                    ds = bllService.GetList(3, "NJL_COMPANY_ID IN(select ID From NJL_COMPANY where NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "') and IMAGE_CODE is not null", "SORT DESC,CREATE_DATE_TIME desc");
                }
                else
                {
                    ds = bllService.GetList(3, "NJL_COMPANY_ID IN(select ID From NJL_COMPANY where NJL_SYS_BASE_ID='" + WEBSITE_CODE + "') and IMAGE_CODE is not null", "SORT DESC,CREATE_DATE_TIME desc");
                }
                rptService.DataSource = ds;
                rptService.DataBind();
                #endregion
                #region 周边同类
                if (WEBSITE_FOCUS_CITY_CODE != "")
                {
                    ds = bllLocalColor.GetList(4, "NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and AREA_CODE!='" + WEBSITE_FOCUS_CITY_CODE + "' AND IS_PUBLISH=1 ", " SORT DESC,CREATE_DATE_TIME desc");
                }
                else
                {
                    ds = bllLocalColor.GetList(4, "NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND IS_PUBLISH=1 ", " SORT DESC,CREATE_DATE_TIME desc");
                }
                rptOtherColor.DataSource = ds;
                rptOtherColor.DataBind();
                #endregion
                #region 热门景点
                NJL.BLL.NJL_ATTRACTION bllAttr = new BLL.NJL_ATTRACTION();
                if (WEBSITE_FOCUS_CITY_CODE != "")
                {
                    ds = bllAttr.GetList(4, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "' AND IS_PUBLISH=1", "SORT DESC,CREATE_DATE_TIME desc");
                }
                else
                {
                    ds = bllAttr.GetList(4, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND IS_PUBLISH=1", "SORT DESC,CREATE_DATE_TIME desc");
                }
                rptHot.DataSource = ds;
                rptHot.DataBind();
                #endregion

            }

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/SearchLocalColor.aspx?keywords=" + txtKeywords.Text.Trim() + "&cc=" + WEBSITE_FOCUS_CITY_NAME_PINYIN);
        }
    }
}